package leetcode.hash;

import java.util.HashMap;
import java.util.List;

/**
 * https://leetcode-cn.com/problems/destination-city/
 *
 * @author mazouri
 * @create 2021-10-01 11:58
 */
public class _1436_destCity {
    public String destCity(List<List<String>> paths) {
        HashMap<String, String> map = new HashMap<>();
        String res = paths.get(0).get(0);

        for (List<String> path : paths)
            map.put(path.get(0), path.get(1));

        while (map.containsKey(res))
            res = map.get(res);

        return res;
    }
}
